<template>
  <el-card style="height: 40%;width: 100%">
    <div>
      <div class="warp__2BP03">
        <div class="warp__1CDpL">
          <div class="warp_l__34yS8">
            ♊&nbsp;&nbsp;<span class="work__00001">求职状态</span>
          </div>
          <div v-if="statusTableData.length===0" class="warp_r__1-t6m">
            <img @click="editJobStatus(null)" class="icon_style__xOInT" alt="" src="">
            <span @click="editJobStatus(null)">编辑</span>
          </div>
        </div><br><br><br><br>
        <el-card shadow="hover" v-if="statusTableData.length!==0" v-for="(item,index) in statusTableData" :key="index">
          <div>
            <span style="font-size: 20px;font-weight: 500;color: #040404;">求职状态</span>
            <span style="margin-left: 30px;font-size: 16px">{{transcodingData(item.status)}}</span>
            <span v-if="item.time!==null && item.status!==4" style="font-size: 20px">/</span>
            <span v-if="item.time!==null && item.status!==4" style="font-size: 16px">{{transcodingData(item.time)}}</span>
            <a style="margin-right: 50px;float: right;">
              <img style="width: 20px; height: 20px" @click="editJobStatus(item)" class="icon_e__36ON5" alt="" src="">
            </a>
          </div>
        </el-card>

        <el-dialog
          style="padding: 40px 50px"
          :visible.sync="dialogVisible"
          width="550px"
          height="450px">
          <span style="margin: 0;font-size: 18px;margin-left: 24px;color: #333;">更新求职状态，让招聘方更了解你</span><br><br>
          <div class="lg-modal-body" style="margin-left: 24px;">
            <div class="modal_title__1ED70">请选择当前状态</div>
            <div class="modal_flex__3fS28">
              <span class="modal_list__3G7z1" :class="{' active__3Bwk5':classNameDataOne===index}" @click="statusEdit(item.id,index)" :key="index" v-for="(item,index) in statusOptions">{{item.name}}</span>
            </div>
            <div v-if="isShow===0" class="modal_title__1ED70">请选择入职时间</div>
            <div v-if="isShow===0" style="justify-content: space-between;" class="modal_times_flex__1_Lej">
              <span class="modal_times_list__3kYL9" :class="{' active__3Bwk5':classNameDataTwo===index}" @click="timeEdit(item.id,index)" :key="index" v-for="(item,index) in timeOptions">{{item.name}}</span>
            </div>
          </div>
          <div class="lg-modal-footer" style="margin-left: 24px;">
            <span class="lg-modal-OK" @click="jobStatusSubmit">确认</span>
            <span class="lg-modal-cancel" @click="dialogVisible = false">取消</span>
          </div>
        </el-dialog>
      </div>
    </div>
  </el-card>
</template>

<script>
export default {
  data () {
    return {
      user: {},
      resume:{},
      dataOptions: [],
      statusOptions: [],
      timeOptions: [],
      statusTableData: [],
      dialogVisible: false,
      form:{
        id: '',
        status: '',
        time: '',
        resumeId: ''
      },
      classNameDataOne: '',
      classNameDataTwo: '',
      isShow: 0
    }
  },
  methods: {
    transcodingData(val){//转码
      for (let i=0;i<this.dataOptions.length;i++){
        let data = this.dataOptions[i];
        if (data.id===val){//状态
          return data.name;
        }
      }
    },
    statusEdit(val,index){//动态class
      this.classNameDataOne = index;
      this.form.status = val;
      if (val===4){
        this.isShow = val;
      }else{
        this.isShow = 0;
      }
    },
    timeEdit(val,index){////动态class
      this.classNameDataTwo = index;
      this.form.time = val;
    },
    jobStatusSubmit(){//编辑
      if (this.form.status===''){
        this.$message({
          message: '当前状态不能为空！',
          type: 'error'
        });
        return;
      }
      if (this.form.time==='' && this.form.status!==4){
        this.$message({
          message: '入职时间不能为空！',
          type: 'error'
        });
        return;
      }
      this.$http({
        url: this.$http.adornUrl(`/resume/status/${!this.form.id ? 'save' : 'update'}`),
        method: 'post',
        data: this.$http.adornData({
          'id': this.form.id || undefined,
          'status': this.form.status,
          'time': this.form.time,
          'resumeId': this.form.resumeId
        })
      }).then(({data}) => {
        if (data.msg==='success'){
          this.$message({
            message: '求职状态保存成功！',
            type: 'success',
            duration: '1200'
          });
        }else{
          this.$message.error('求职状态保存失败！');
        }
        this.dialogVisible = false;
        this.findData();
      })
    },
    findUserData(){//获取当前用户信息
      //this.user = JSON.parse(localStorage.getItem("user"))
        this.resume= JSON.parse(localStorage.getItem("resume"));
      this.form.resumeId = this.resume.id;
    },
    findJobStatusData(){//获取用户的求职状态
      this.$http({
        url: this.$http.adornUrl(`/resume/status/list/${this.resume.id}`),
        method: 'get'
      }).then(({data}) => {
        if(data.data!='') {
          this.$emit('resumTest')
          this.statusTableData = data.data
        }
      })
    },
    async findData(){//获取数据
      this.findUserData();
      this.findJobStatusData();
      //获取求职状态数据
      await this.$http({
        url: this.$http.adornUrl('/hope/status'),
        method: 'get'
      }).then(({data}) => {
        this.dataOptions = data;
        this.statusOptions = []
        this.timeOptions = []
        for (let i=0;i<data.length;i++){
          let value = data[i];
          if (value.pid===0){//状态
            this.statusOptions.push(value)
          }
          if (value.pid===1){//时间
            this.timeOptions.push(value)
          }
        }
      })
    },
    editJobStatus(val){//编辑
      if (val!==null){
        this.form = val;
        for (let i=0;i<this.statusOptions.length;i++){
          if (this.statusOptions[i].id===this.form.status){
            this.statusEdit(this.statusOptions[i].id,i);
          }
        }
        for (let i=0;i<this.timeOptions.length;i++){
          if (this.timeOptions[i].id===this.form.time){
            this.timeEdit(this.timeOptions[i].id,i);
          }
        }
      }
      this.dialogVisible = true
    }
  },
  created () {
    this.findData();
  }
}
</script>

<style scoped>

  .warp__1CDpL .warp_r__1-t6m .icon_style__xOInT {
    width: 14px;
    height: 14px;
    margin-right: 5px;
    vertical-align: middle;
  }

  .warp__1CDpL .warp_r__1-t6m {
    margin-right: 50px;
    float: right;
    font-size: 14px;
    font-weight: 400;
    color: #02B28A;
    line-height: 28px;
    cursor: pointer;
  }

  .a1{
    border-left: 3px solid #00B38A;
    height: 16px;
    position: absolute;
    top: 24px;
    /*left: 30px;*/
  }

  .work__00001{
    font-size: 20px;
    font-weight: 600;
    color: #040404;
  }

  .warp_from__3BK0q {
    /*width: 780px;*/
    /*margin: 30px auto;*/
    padding: 30px 40px;
    /*padding-top: 0;*/
    background: #F8F9FB;
    border-radius: 2px;
    border: 1px dashed #E8E9EB;
  }

  .warp_from__3BK0q .title__12Fjr {
    margin: 30px 0;
    font-size: 16px;
    font-weight: 600;
    color: #00B38A;
  }

  .warp_from__3BK0q .input_warp__2AFbs {
    position: relative;
  }

  .warp_from__3BK0q .input_warp__2AFbs .fl_input_all__17UYa {
    margin-bottom: 20px;
  }

  .lg-form-item:first-child {
    margin-top: 0;
  }

  .lg-form-item {
    position: relative;
    margin-top: 22px;
  }

  .warp_from__3BK0q .input_warp__2AFbs .fl_input_all__17UYa div:first-child {
    width: 85px;
  }

  .lg-form-horizontal .lg-form-item-label {
    margin-bottom: 0;
    width: 90px;
  }

  .lg-form-horizontal .lg-form-item-label, .lg-form-horizontal .lg-form-item-control {
    display: inline-block;
  }

  .lg-form-item-label {
    margin-bottom: 10px;
    font-size: 14px;
    color: #333;
    vertical-align: top;
  }

  .lg-form-horizontal .lg-form-item-label label {
    display: block;
    height: 40px;
    line-height: 40px;
    text-align: right;
  }

  .warp_from__3BK0q .input_warp__2AFbs .fl_input_all__17UYa div:last-child {
    width: 576px;
  }

  .lg-form-horizontal .lg-form-item-control {
    width: 300px;
    margin-left: 20px;
  }

  .lg-form-horizontal .lg-form-item-label, .lg-form-horizontal .lg-form-item-control {
    display: inline-block;
  }

  .lg-form-item-control {
    position: relative;
  }

  .lg-input-affix-wrapper {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    color: #333;
    font-size: 14px;
    line-height: 1.5;
    list-style: none;
    position: relative;
    display: inline-block;
    width: 100%;
    text-align: start;
  }

  .lg-form-item-control.feedback .lg-input {
    padding-right: 30px;
  }

  .lg-input-affix-wrapper .lg-input:not(:last-child) {
    padding-right: 30px;
  }

  .lg-input-affix-wrapper .lg-input {
    min-height: 100%;
  }

  .lg-input-affix-wrapper .lg-input {
    position: relative;
    text-align: inherit;
  }

  input[type=text], input[type=password], textarea {
    font-family: "Microsoft Yahei", "SimSun", Arial, "Helvetica Neue", Helvetica;
  }

  a, area, button, [role='button'], input:not([type='range']), label, select, summary, textarea {
    touch-action: manipulation;
  }

  input[type='text'], input[type='password'], input[type='number'], textarea {
    -webkit-appearance: none;
  }

  button, input, optgroup, select, textarea {
    margin: 0;
    padding: 0;
    border: 1px solid #ededed;
    border-radius: 0;
    font-family: "Hiragino Sans GB", "Microsoft Yahei", "SimSun", Arial, "Helvetica Neue", Helvetica;
  }

  .lg-input-affix-wrapper .lg-input-suffix {
    right: 12px;
  }

  .lg-input-affix-wrapper .lg-input-prefix, .lg-input-affix-wrapper .lg-input-suffix {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: flex;
    align-items: center;
    color: #333;
    line-height: 0;
    transform: translateY(-50%);
  }

  [class^="icon-lg-"], [class*=" icon-lg-"] {
    font-family: "lagou-icon" !important;
    font-style: normal;
    font-weight: normal;
    text-transform: none;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  .lg-input-affix-wrapper {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    color: #333;
    font-size: 14px;
    line-height: 1.5;
    list-style: none;
    position: relative;
    display: inline-block;
    width: 100%;
    text-align: start;
  }

  .lg-input-affix-wrapper .lg-input-suffix {
    right: 12px;
  }

  .lg-input-affix-wrapper .lg-input-prefix, .lg-input-affix-wrapper .lg-input-suffix {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: flex;
    align-items: center;
    color: #333;
    line-height: 0;
    transform: translateY(-50%);
  }

  [class^="icon-lg-"], [class*=" icon-lg-"] {
    font-family: "lagou-icon" !important;
    font-style: normal;
    font-weight: normal;
    text-transform: none;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  *, *::before, *::after {
    box-sizing: border-box;
  }

  .warp_from__3BK0q .input_warp__2AFbs {
    position: relative;
  }

  .lg-form-item:first-child {
    margin-top: 0;
  }

  .lg-form-item {
    position: relative;
    margin-top: 22px;
  }

  .warp_from__3BK0q .input_warp__2AFbs .fl_select__3zVXB > div:first-child {
    width: 85px;
  }

  .lg-form-horizontal .lg-form-item-label {
    margin-bottom: 0;
    width: 90px;
  }

  .lg-form-horizontal .lg-form-item-label, .lg-form-horizontal .lg-form-item-control {
    display: inline-block;
  }

  .lg-form-item-label {
    margin-bottom: 10px;
    font-size: 14px;
    color: #333;
    vertical-align: top;
  }

  .lg-form-horizontal .lg-form-item-label label {
    display: block;
    height: 40px;
    line-height: 40px;
    text-align: right;
  }

  .warp_from__3BK0q .input_warp__2AFbs .fl_select__3zVXB > div:last-child {
    width: 580px;
  }

  .lg-form-horizontal .lg-form-item-control {
    width: 300px;
    margin-left: 20px;
  }

  .lg-form-horizontal .lg-form-item-label, .lg-form-horizontal .lg-form-item-control {
    display: inline-block;
  }

  .lg-form-item-control {
    position: relative;
  }

  element.style {
    width: 49%;
    margin-right: 2%;
  }

  .lg-select-lg .lg-select-selection--single {
    height: 40px;
  }

  .lg-select-lg .lg-select-selection__rendered {
    line-height: 38px;
  }

  .lg-select-selection--single .lg-select-selection__rendered {
    margin-right: 24px;
  }

  element.style {
    display: block;
    opacity: 1;
  }

  .warp_from__3BK0q .input_warp__2AFbs .lg-select-selection-selected-value {
    font-size: 16px;
  }

  *, *::before, *::after {
    box-sizing: border-box;
  }

  element.style {
    user-select: none;
  }

  .lg-select-arrow .lg-select-arrow-icon {
    transition: transform 0.3s;
  }

  [class^="icon-lg-"], [class*=" icon-lg-"] {
    font-family: "lagou-icon" !important;
    font-style: normal;
    font-weight: normal;
    text-transform: none;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  *, *::before, *::after {
    box-sizing: border-box;
  }

  element.style {
    width: 49%;
  }

  .lg-select-lg .lg-select-selection--single {
    height: 40px;
  }

  .lg-select-lg .lg-select-selection__rendered {
    line-height: 38px;
  }

  .lg-select-selection--single .lg-select-selection__rendered {
    margin-right: 24px;
  }

  element.style {
    display: block;
    opacity: 1;
  }

  .warp_from__3BK0q .input_warp__2AFbs .lg-select-selection-selected-value {
    font-size: 16px;
  }

  *, *::before, *::after {
    box-sizing: border-box;
  }

  element.style {
    user-select: none;
  }

  .lg-select-arrow .lg-select-arrow-icon {
    transition: transform 0.3s;
  }

  [class^="icon-lg-"], [class*=" icon-lg-"] {
    font-family: "lagou-icon" !important;
    font-style: normal;
    font-weight: normal;
    text-transform: none;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  *, *::before, *::after {
    box-sizing: border-box;
  }

  .button_w__9UtkX {
    margin-top: 20px;
    margin-left: 76px;
  }

  .myresume_container__3kIcL .fl_w__UKyBE .fl_l__297YX {
    float: left;
  }

  element.style {
    width: 88px;
  }

  .lgPrimaryButton__IV-Ot {
    background: #00b38a;
    border-radius: 2px;
    color: #ffffff;
  }

  .lgButton__1UxBx {
    width: 100px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    border-radius: 2px;
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    cursor: pointer;
    margin-right: 10px;
  }

  .myresume_container__3kIcL .fl_w__UKyBE .fl_l__297YX {
    float: left;
  }

  button, html [type="button"], [type="reset"], [type="submit"] {
    -webkit-appearance: button;
  }

  .lg-button {
    display: inline-block;
    margin: 0;
    line-height: 1;
    white-space: nowrap;
    border: 1px solid #c4c4c4;
    text-shadow: none;
    box-shadow: none;
    cursor: pointer;
    outline: none;
    padding: 10px 15px;
    font-size: 12px;
    border-radius: 2px;
  }

  .work_btn_cancel__1XEeL {
    height: 40px;
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #666666;
    margin-left: 10px;
  }

  label, select, button, input[type="button"], input[type="reset"], input[type="submit"], input[type="radio"], input[type="checkbox"], input[type="file"] {
    cursor: pointer;
  }

  button, input, optgroup, select, textarea {
    margin: 0;
    padding: 0;
    border: 1px solid #ededed;
    border-radius: 0;
    font-family: "Hiragino Sans GB", "Microsoft Yahei", "SimSun", Arial, "Helvetica Neue", Helvetica;
  }

  button, select {
    text-transform: none;
  }

  button, input {
    overflow: visible;
  }

  input, button, select, optgroup, textarea {
    margin: 0;
    color: inherit;
    font-size: inherit;
    font-family: inherit;
    line-height: inherit;
  }

  .myresume_container__3kIcL .fl_w__UKyBE:after {
    content: '';
    height: 0;
    line-height: 0;
    display: block;
    visibility: hidden;
    clear: both;
  }

  *, *::before, *::after {
    box-sizing: border-box;
  }

  .lg-button-text {
    padding-left: 0;
    padding-right: 0;
    color: #00b38a;
    border-color: transparent;
    background-color: transparent;
  }

  .lg-modal-body {
    position: relative;
    font-size: 14px;
    color: #555;
  }

  .modal_title__1ED70 {
    margin-top: 30px;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    line-height: 20px;
  }

  .modal_flex__3fS28 {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
  }

  .modal_list__3G7z1.active__3Bwk5 {
    background: rgba(0, 179, 138, 0.11);
    color: #00B38A;
  }

  .modal_list__3G7z1 {
    text-align: center;
    margin-top: 10px;
    width: 196px;
    height: 40px;
    background: rgba(244, 244, 246, 0.51);
    border-radius: 3px;
    font-weight: 400;
    color: #666;
    line-height: 40px;
    margin-right: 8px;
    cursor: pointer;
  }

  .modal_title__1ED70 {
    margin-top: 30px;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    line-height: 20px;
  }

  .modal_times_flex__1_Lej {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
  }

  .modal_times_flex__1_Lej .modal_times_list__3kYL9 {
    width: 141px;
    text-align: center;
    margin-top: 10px;
    height: 40px;
    background: rgba(244, 244, 246, 0.51);
    border-radius: 3px;
    font-weight: 400;
    color: #666;
    line-height: 40px;
    margin-right: 8px;
    cursor: pointer;
  }

  .modal_times_flex__1_Lej .modal_times_list__3kYL9.active__3Bwk5 {
    background: rgba(0, 179, 138, 0.11);
    color: #00B38A;
  }

  .lg-modal-footer {
    position: relative;
    margin-top: 30px;
    text-align: left;
    box-sizing: border-box;
  }

  .lg-modal-OK {
    background-color: #00b38a;
    color: #fff;
    border-radius: 2px;
  }

  .lg-modal-OK, .lg-modal-cancel {
    display: inline-block;
    padding: 0 25px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
  }

  .lg-modal-cancel {
    padding: 0 25px;
    color: #666;
  }

  .lg-modal-OK, .lg-modal-cancel {
    display: inline-block;
    padding: 0 25px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
  }


</style>
